home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / AmiVoGL_MDEV.lha / drivers / ibmpc / vga.c < prev   
Text File  |  1991-09-29  |  2KB  |  125 lines

  1. #include    "vogl.h"
  2.  
  3. /* 
  4.  * Note, vga can't do double buffering by page swapping...`
  5.  */
  6.  
  7. #define    V_PIX_ASPECT    1.0
  8.  
  9. static    int    old_mode;
  10. extern    unsigned    int    _buffer_segment;
  11. extern    unsigned    int    _buffer_offset;
  12.  
  13. extern    int
  14.         vega_char(),
  15.         vega_clear(),
  16.         vega_color(),
  17.         vega_draw(),
  18.         vega_setpal(),
  19.         pc_fill(),
  20.         vega_font(),
  21.         pc_getkey(),
  22.         pc_checkkey(),
  23.         pc_locator(),
  24.         vega_string(),
  25.         setmode();
  26.  
  27.  
  28. static int
  29. vga_init()
  30. {
  31.     old_mode = setmode(18);
  32.     vdevice.sizeX = 479 * V_PIX_ASPECT;
  33.     vdevice.sizeY = 479;
  34.     vdevice.sizeSx = 639;
  35.     vdevice.sizeSy = 479;
  36.     vdevice.depth = 4;
  37.     _buffer_segment = 0xA000;
  38.     _buffer_offset = 0;
  39.     pc_locinit(vdevice.sizeSx, vdevice.sizeSy);
  40.     zsetup();
  41.     vega_setpal();
  42.     return (1);
  43. }
  44.  
  45.  
  46. /* 
  47.  * vga_vclear
  48.  *
  49.  *    Just clears the current viewport.
  50.  */
  51. static
  52. vga_vclear()
  53. {
  54.     int     x[4], y[4];
  55.  
  56.     if (vdevice.maxVx != vdevice.sizeSx
  57.         || vdevice.maxVy != vdevice.sizeSy
  58.         || vdevice.minVx != vdevice.sizeSx
  59.         || vdevice.minVy != vdevice.sizeSy) {
  60.         x[0] = x[3] = vdevice.minVx;
  61.         y[0] = y[1] = vdevice.maxVy;
  62.         y[2] = y[3] = vdevice.minVy;
  63.         x[1] = x[2] = vdevice.maxVx;
  64.  
  65.         pc_fill(5, x, y);
  66.     } else {
  67.         vega_clear();
  68.     }
  69.  
  70.     return(0);
  71. }
  72.  
  73. /*
  74.  * vga_exit
  75.  *
  76.  *    Sets the display back to text mode.
  77.  */
  78. static
  79. vga_exit()
  80. {
  81.     (void)setmode(old_mode);
  82.     return (1);
  83. }
  84.  
  85. static    int
  86. noop()
  87. {
  88.     return (-1);
  89. }
  90.  
  91. static DevEntry vgadev = {
  92.     "vga",
  93.     "large",
  94.     "small",
  95.     noop,
  96.     vega_char,
  97.     pc_checkkey,
  98.     vga_vclear,
  99.     vega_color,
  100.     vega_draw,
  101.     vga_exit,
  102.     pc_fill,
  103.     vega_font,
  104.     noop,
  105.     pc_getkey,
  106.     vga_init,
  107.     pc_locator,
  108.     noop,
  109.     vega_string,
  110.     noop
  111. };
  112.  
  113. /*
  114.  * _vga_devcpy
  115.  *
  116.  *    copy the pc device into vdevice.dev.
  117.  */
  118. _vga_devcpy()
  119. {
  120.     vdevice.dev = vgadev;
  121.  
  122.     return(0);
  123. }
  124.  
  125.